package com.firexxx.vp.domain.vp;

import com.firexxx.vp.domain.vp.single.mlvdata.MlvModelData;
import com.firexxx.vp.utils.MatrixUtil;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.RealMatrix;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2020/01/16 16:26
 */
public class VoicePrintModelMatrixService {

    public static double[] lppReduceDimension(MlvModelData mlvModelData, RealMatrix lppMatrix) {
        float[] simple_plp_tv = mlvModelData.getPlp_tv().getData();
        float[] simple_pncc_tv = mlvModelData.getPncc_tv().getData();

        double[] array = MatrixUtil.connectArry(simple_plp_tv, simple_pncc_tv);

        // LPP降维，plpAndPnccIvectorArr与LPP矩阵相乘
        RealMatrix ivectorMatrix = new Array2DRowRealMatrix(array);

        ivectorMatrix = ivectorMatrix.transpose();
        RealMatrix realMatrix = ivectorMatrix.multiply(lppMatrix);

        return realMatrix.getData()[0];
    }

}